package com.yssw.account.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yssw.common.annotation.Log;
import com.yssw.common.core.controller.BaseController;
import com.yssw.common.core.domain.AjaxResult;
import com.yssw.common.enums.BusinessType;
import com.yssw.account.domain.AccountTable;
import com.yssw.account.service.IAccountTableService;
import com.yssw.common.utils.poi.ExcelUtil;
import com.yssw.common.core.page.TableDataInfo;

/**
 * 账户信息Controller
 * 
 * @author yssw
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/account/account")
public class AccountTableController extends BaseController
{
    @Autowired
    private IAccountTableService accountTableService;

    /**
     * 查询账户信息列表
     */
    @PreAuthorize("@ss.hasPermi('account:account:list')")
    @GetMapping("/list")
    public TableDataInfo list(AccountTable accountTable)
    {
        startPage();
        List<AccountTable> list = accountTableService.selectAccountTableList(accountTable);
        return getDataTable(list);
    }

    /**
     * 导出账户信息列表
     */
    @PreAuthorize("@ss.hasPermi('account:account:export')")
    @Log(title = "账户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountTable accountTable)
    {
        List<AccountTable> list = accountTableService.selectAccountTableList(accountTable);
        ExcelUtil<AccountTable> util = new ExcelUtil<AccountTable>(AccountTable.class);
        util.exportExcel(response, list, "账户信息数据");
    }

    /**
     * 获取账户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('account:account:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountTableService.selectAccountTableById(id));
    }

    /**
     * 新增账户信息
     */
    @PreAuthorize("@ss.hasPermi('account:account:add')")
    @Log(title = "账户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountTable accountTable)
    {
        return toAjax(accountTableService.insertAccountTable(accountTable));
    }

    /**
     * 修改账户信息
     */
    @PreAuthorize("@ss.hasPermi('account:account:edit')")
    @Log(title = "账户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountTable accountTable)
    {
        return toAjax(accountTableService.updateAccountTable(accountTable));
    }

    /**
     * 删除账户信息
     */
    @PreAuthorize("@ss.hasPermi('account:account:remove')")
    @Log(title = "账户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accountTableService.deleteAccountTableByIds(ids));
    }
}
